From 2b039aa937752ae9736d82a4344efa792ecc2d0f Mon Sep 17 00:00:00 2001 From: "smh22@firebug.cl.cam.ac.uk" Date: Thu, 1 Dec 2005 20:43:04 +0100 Subject: [PATCH] Fix VBD recovery logic on SMP guests (+ a minor error reporting fix for save) Signed-off-by: Steven Hand --- .../drivers/xen/blkfront/blkfront.c | 28 +++++++++++++------ tools/libxc/xc_linux_save.c | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c index 7357d14b60..0200c779fb 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -300,6 +300,10 @@ static void backend_changed(struct xenbus_device *dev, /* ** Connection ** */ +/* +** Invoked when the backend is finally 'ready' (and has told produced +** the details about the physical device - #sectors, size, etc). +*/ static void connect(struct blkfront_info *info) { unsigned long sectors, sector_size; @@ -324,20 +328,17 @@ static void connect(struct blkfront_info *info) return; } - info->connected = BLKIF_STATE_CONNECTED; xlvbd_add(sectors, info->vdevice, binfo, sector_size, info); - - err = xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected); - if (err) - return; + + (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected); /* Kick pending requests. */ spin_lock_irq(&blkif_io_lock); + info->connected = BLKIF_STATE_CONNECTED; kick_pending_request_queues(info); spin_unlock_irq(&blkif_io_lock); } - /** * Handle the change of state of the backend to Closing. We must delete our * device-layer structures now, to ensure that writes are flushed through to @@ -770,11 +771,20 @@ static void blkif_recover(struct blkfront_info *info) kfree(copy); - /* Kicks things back into life. */ + (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected); + + /* Now safe for us to use the shared ring */ + spin_lock_irq(&blkif_io_lock); + info->connected = BLKIF_STATE_CONNECTED; + spin_unlock_irq(&blkif_io_lock); + + /* Send off requeued requests */ flush_requests(info); - /* Now safe to let other people use the interface. */ - info->connected = BLKIF_STATE_CONNECTED; + /* Kick any other new requests queued since we resumed */ + spin_lock_irq(&blkif_io_lock); + kick_pending_request_queues(info); + spin_unlock_irq(&blkif_io_lock); } diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c index 2d15ee587d..1c32ed8a80 100644 --- a/tools/libxc/xc_linux_save.c +++ b/tools/libxc/xc_linux_save.c @@ -677,7 +677,7 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, live_shinfo->arch.pfn_to_mfn_frame_list_list); if (!live_p2m_frame_list_list) { - ERR("Couldn't map p2m_frame_list_list"); + ERR("Couldn't map p2m_frame_list_list (errno %d)", errno); goto out; } -- 2.30.2